# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=lite-xl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1.7
pkgrel=1
pkgdesc='A lightweight text editor written in Lua (mingw-w64)'
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: lite-xl'
)
msys2_repository_url='https://github.com/lite-xl/lite-xl'
url='https://lite-xl.com/'
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-freetype"
  "${MINGW_PACKAGE_PREFIX}-lua"
  "${MINGW_PACKAGE_PREFIX}-pcre2"
  "${MINGW_PACKAGE_PREFIX}-SDL2"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
)
source=("https://github.com/lite-xl/lite-xl/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "0001-lite-xl-meson-fix-install.patch")
sha256sums=('69d1ce4c1d148d382ccb06f45feca2565c5c8fe9d0b1b9bc1cbe014f6826ce6b'
            '30162cd66c9a72325f86d358d2bbae455c9ae28cfb158a983773bbdc8b0984c1')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-lite-xl-meson-fix-install.patch"
}

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      -Duse_system_lua=true \
      ${_realname}-${pkgver} \
      build-${MSYSTEM}

  "${MINGW_PREFIX}"/bin/meson.exe compile -C build-${MSYSTEM}
}

package() {
  "${MINGW_PREFIX}"/bin/meson.exe install -C build-${MSYSTEM} --destdir "${pkgdir}"
}
